
 package com.ami.iusb;
 
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.RandomAccessFile;
 
 
 
 
 
 
 public class MountFolder
   extends Thread
 {
   public String folderPath = null;
   public String imagePath = null;
   public int imageSize = 0;
   public long imageCreateTime = 0L;
   RandomAccessFile pImg = null;
   MBR ptable = null;
   public int action_flag = 0;
   
   public int image_result = 0;
   
 
   public MountFolder(int paramInt, String paramString1, String paramString2)
   {
     this.imageSize = paramInt;
     this.folderPath = paramString1;
     this.imagePath = paramString2;
   }
   
   public void createMBR() {
     if (this.action_flag == 1) {
       this.ptable = new MBR(this.imagePath, this.folderPath, this.imageSize);
       this.imageCreateTime = this.ptable.image_create_time;
     }
     else {
       try {
         this.pImg = new RandomAccessFile(this.imagePath, "rw");
         this.ptable = new MBR(this.pImg);
       }
       catch (IOException localIOException) {
         localIOException.printStackTrace();
       }
     }
   }
   
   public void run() {
     this.image_result = 0;
     if (this.action_flag == 1) {
       createImage();
       if (this.ptable.folder_size == 0L) {
         this.ptable.complete_percent = 100;
       }
     } else {
       syncToDisk();
     }
   }
   
   public int getPercent()
   {
     if (this.ptable != null) {
       return this.ptable.complete_percent;
     }
     return 100;
   }
   
   public boolean ImageSizeCheck()
   {
     File localFile = new File(this.folderPath);
     long l1 = 0L;
     long l2 = this.imageSize * 1000L * 1024L * 1024L;
     
     l1 = MBR.getFileFolderSize(localFile);
     if (l1 > l2) {
       return false;
     }
     
     this.ptable.folder_size = l1;
     return true;
   }
   
   public void stopRun()
   {
     this.ptable.setStopFlag();
   }
   
   public void createImage()
   {
     this.ptable.getImageFilePointer();
     this.image_result = this.ptable.createImage(this.folderPath);
   }
   
   public void stopAccessImage()
   {
     if (this.ptable != null) {
       this.ptable.closeChannel();
       this.ptable = null;
     }
     try
     {
       if (this.pImg != null) {
         this.pImg.close();
         this.pImg = null;
       }
     }
     catch (Exception localException) {
       localException.printStackTrace();
     }
   }
   
   public void syncToDisk() {
     try {
       File localFile = new File(this.folderPath);
       if (!localFile.exists()) {
         localFile.mkdirs();
       }
       this.ptable.image_create_time = this.imageCreateTime;
       this.ptable.getBootSectorInfo(0);
       
       this.ptable.getFileList(localFile.getPath());
       this.ptable.folderSizeCalculate();
       
       if (this.ptable.using_fat16) {
         this.image_result = this.ptable.listFilesFromImage(this.ptable.root_start_addr, localFile.getPath() + File.separator, null, MBR.NON_MULTI_CLUSTER);
 
       }
       else
       {
         long l1 = 0L;
         long l2 = 0L;
         long l3 = 0L;
         long[] arrayOfLong = new long[1];
         
         l3 = this.ptable.root_start_addr;
         
         l1 = (l3 - this.ptable.data_start_addr) / (this.ptable.sector_size * this.ptable.sectors_per_cluster) + MBR.FAT_RESERVED_RECORD_NUM;
         
         arrayOfLong[0] = l1;
         try
         {
           for (;;)
           {
             this.pImg.seek(this.ptable.fat_start_addr + l1 * MBR.FAT_RECORD_SIZE);
             l2 = MBR.ChangeToLittleEndian(this.pImg.readInt(), 4, MBR.LITTLE_ENDIAN_TYPE);
             
             if (l2 == 268435455L) break;
             arrayOfLong = this.ptable.extendLong(arrayOfLong, l2);
             
 
             l3 = this.ptable.data_start_addr + (l2 - MBR.FAT_RESERVED_RECORD_NUM) * (this.ptable.sector_size * this.ptable.sectors_per_cluster);
             
             l1 = (l3 - this.ptable.data_start_addr) / (this.ptable.sector_size * this.ptable.sectors_per_cluster) + MBR.FAT_RESERVED_RECORD_NUM;
           }
           
 
         }
         catch (IOException localIOException)
         {
           localIOException.printStackTrace();
         }
         
         if (arrayOfLong.length > 1) {
           for (int i = 0; i < arrayOfLong.length; i++) {
             long l5 = 0L;
             l5 = this.ptable.data_start_addr + (arrayOfLong[i] - MBR.FAT_RESERVED_RECORD_NUM) * (this.ptable.sector_size * this.ptable.sectors_per_cluster);
           }
           
 
           long l4 = 0L;
           for (int j = 0; j < arrayOfLong.length; j++) {
             l4 = this.ptable.data_start_addr + (arrayOfLong[j] - MBR.FAT_RESERVED_RECORD_NUM) * (this.ptable.sector_size * this.ptable.sectors_per_cluster);
             this.image_result = this.ptable.listFilesFromImage(l4, localFile.getPath() + File.separator, arrayOfLong, j);
             if (this.image_result < 0) {
               return;
             }
           }
         }
         else {
           this.image_result = this.ptable.listFilesFromImage(this.ptable.root_start_addr, localFile.getPath() + File.separator, null, MBR.NON_MULTI_CLUSTER);
         }
       }
       this.ptable.delFileCheck();
 
     }
     catch (Exception localException)
     {
       System.out.println(localException);
     }
   }
 }


/* Location:              D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\iusb\MountFolder.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */